<!--
 * @Author: error: git config user.name && git config user.email & please set dead value or install git
 * @Date: 2023-01-02 20:02:50
 * @LastEditors: 朱安武 549410045@qq.com
 * @LastEditTime: 2023-01-06 22:17:18
 * @FilePath: \elementUi\src\components\MainHeader.vue
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
-->
<template>
  <div class="title">
    <el-breadcrumb separator="/"  >
      <el-breadcrumb-item v-for="(path,index) in aisdeList" :key="path" :to="{ path:pathList[index+2]}">
        {{ path }}
      </el-breadcrumb-item>
    </el-breadcrumb>
    <el-dropdown trigger="click">
        <span class="el-dropdown-link">
          {{ adminname }}
          <el-icon class="el-icon--right"><arrow-down /></el-icon>
        </span>
        <template #dropdown>
          <el-dropdown-menu>
            <el-dropdown-item @click="logout">退出登录</el-dropdown-item>
          </el-dropdown-menu>
        </template>
      </el-dropdown>
  </div>
  </template>
<script setup>
import { router,pathList} from '../router';
import { reactive } from 'vue'
import { useAdminStore,aisdeList } from '../stores/admin-store';

//使用pinia获取id
const adminId = useAdminStore()
const adminname = adminId.adminname 

//退出
const logout = ()=>{
  //清空localStorage
  localStorage.removeItem('token')
  localStorage.removeItem('adminname')
  //清空store
  adminId.setAdminStore('')
  //跳回登录页
  router.push('/login')
}

</script>
<style scoped>
.title{
  display: flex;
  justify-content: space-between;
  margin-top: 10px;
}
</style>